package com.oa.business.user;

import com.oa.common.result.Result;
import com.oa.framework.acc.excuse.domain.AccountExcuse;
import com.oa.framework.acc.excuse.service.AccountExcuseService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/excuse")
public class ExcuseController {

    @Autowired
    private AccountExcuseService excuseService;
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private TaskService taskService;

    @RequestMapping("test")
    public Result test(){
        AccountExcuse excuse = new AccountExcuse();
        excuse.setAccountId(1L);
        excuse.setCreateTime(new Date());
        excuse.setStartTime(new Date());
        excuse.setEndTime(new Date());
        excuse.setDescription("测试请假");
        AccountExcuse excuseNew = excuseService.startExcuseProcess(excuse);
        return Result.success(excuseNew);

    }


    @RequestMapping("test1")
    public Result test1(){
        String instanceId = "a91f6ccf-af08-11eb-b808-085700c87e55";

        Task task = taskService.createTaskQuery().active().taskCandidateGroup("bumen").singleResult();
        return Result.success(task.getId());
    }
}
